//
//  GasListTabVC.m
//  NtoccDriverNew
//
//  Created by niyongsheng on 2022/10/18.
//  Copyright © 2022 GCY. All rights reserved.
//

#import "GasListTabVC.h"
#import "SGPagingView.h"
#import "GasListVC.h"

@interface GasListTabVC ()
<
SGPageTitleViewDelegate,
SGPageContentCollectionViewDelegate
>
@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentCollectionView *pageContentCollectionView;


@end

@implementation GasListTabVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"加油列表";
    
    [self setupPageView];
}

- (void)setupPageView {
    
    CGFloat statusHeight = CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
    CGFloat pageTitleViewY = 0;
    if (statusHeight == 20.0) {
        pageTitleViewY = 64;
    } else {
        pageTitleViewY = 88;
    }
    
    NSArray *orderStatusArr;
    NSArray *orderTitleArr;
    
    orderStatusArr = @[@"", @"0", @"1", @"2", @"3", @"4"];
    orderTitleArr = @[@"全部", @"待付款", @"付款中", @"已付款", @"已退款", @"已取消"];
    
    SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
    configure.indicatorStyle = SGIndicatorStyleDynamic;
    configure.titleFont = font(17);
    configure.titleColor = Dark_TextColor;
    configure.titleSelectedColor = Theme_ColorValue;
    configure.indicatorColor = Theme_ColorValue;
    configure.indicatorDynamicWidth = 40;
    configure.indicatorHeight = 3.0f;
    configure.showBottomSeparator = NO;
    configure.titleAdditionalWidth = 35;
    configure.badgeColor = [UIColor redColor];
    
    /// pageTitleView
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, 1, ScreenW, 44) delegate:self titleNames:orderTitleArr configure:configure];
    self.pageTitleView.selectedIndex = _selectedIndex;
    [self.view addSubview:_pageTitleView];
    
    NSMutableArray *childArr = [[NSMutableArray alloc] init];
    for (int i=0; i<orderTitleArr.count; i++) {
        GasListVC *ydcvc = [[GasListVC alloc] init];
        ydcvc.transactionStatus = orderStatusArr[i];
        ydcvc.typeStr = self.typeStr;
        [childArr addObject:ydcvc];
    }
    /// pageContentCollectionView
    CGFloat ContentCollectionViewHeight = self.view.frame.size.height - CGRectGetMaxY(_pageTitleView.frame);
    self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_pageTitleView.frame), ScreenW, ContentCollectionViewHeight) parentVC:self childVCs:childArr];
    _pageContentCollectionView.delegatePageContentCollectionView = self;
    [self.view addSubview:_pageContentCollectionView];
}

- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
    [self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
}

- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
}

@end
